Skip to content

fix(provider): clamp Xiaomi MiMo public reasoning tiers - #1485

Merged
lidge-jun merged 2 commits into
devfrom
agent/fix-1483-xiaomi-reasoning
Aug 12, 2026
Merged

fix(provider): clamp Xiaomi MiMo public reasoning tiers#1485
lidge-jun merged 2 commits into
devfrom
agent/fix-1483-xiaomi-reasoning

Conversation

@Ingwannu

@Ingwannu Ingwannu commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a fixed-destination xiaomi-mimo preset for Xiaomi's official OpenAI-compatible Chat endpoint
  • expose only the upstream-validated low, medium, and high reasoning tiers
  • clamp direct xhigh, max, and ultra requests to high
  • preserve same-named custom providers that point at another destination
  • document the separate public Chat transport and its registry ownership decision

Root cause and impact

https://api.xiaomimimo.com/v1 had no registry-owned transport contract. A custom provider named xiaomi-mimo therefore kept the generic routed-model ladder and could advertise/send max even though the MiMo endpoint rejects every reasoning value above high.

The new preset is intentionally separate from the existing Xiaomi Anthropic and MiMo token-plan entries because those routes use different hosts and transport contracts. preserveCustomDestination prevents the preset from retargeting an existing custom key when a same-named row points somewhere else.

This PR does not normalize the separately reported malformed delta.tool_calls failure. The shared parser remains fail-closed until a redacted failing frame identifies the actual nested shape; guessing there could silently drop or mis-bind a tool call.

Refs #1483.

Provider evidence

Verified from Xiaomi's primary sources on 2026-08-11:

  • Official OpenAI-compatible Chat reference: https://platform.xiaomimimo.com/docs/en-US/api/chat/openai-api documents POST https://api.xiaomimimo.com/v1/chat/completions and API-key/Bearer authentication.
  • Service terms: https://mimo.mi.com/docs/terms/user-agreement identify Xiaomi Technologies Singapore Pte. Ltd. as the API service operator outside mainland China; the agreement was updated 2026-07-07.
  • Privacy terms: https://mimo.mi.com/docs/terms/privacy-policy identify Xiaomi Technology Netherlands B.V. and Xiaomi Technologies Singapore Pte. Ltd.; the policy was updated 2026-03-17.
  • Aggregator authorization: not applicable. This preset sends a user key to Xiaomi's first-party endpoint for Xiaomi's own MiMo model; it does not resell or route third-party models.
  • OpenCodex maintenance owner: @Ingwannu. Endpoint/auth/catalog breakage should be reported in the OpenCodex issue tracker and will be rechecked against the primary sources above.
  • The preset does not declare live model discovery, so no authenticated GET /v1/models contract is claimed.

Verification

  • bun test tests/mimo-token-plan-provider.test.ts tests/provider-registry-parity.test.ts — 41 passed
  • bun test tests/provider-workspace-rail.test.ts — 6 passed after installing the GUI workspace dependencies
  • bun run typecheck — passed
  • bun run privacy:scan — passed
  • cd docs-site && bun install --frozen-lockfile && bun run build — 265 pages built
  • bun run test — 11,047 passed, 11 skipped, 2 failed across 681 files; the failures were the live service-token environment collision in codex-shim.test.ts and a loaded-runner stall deadline in bridge-lifecycle.test.ts
  • env -u OPENCODEX_API_AUTH_TOKEN bun test tests/codex-shim.test.ts tests/bridge-lifecycle.test.ts — both failed files passed in isolation, 82/82
  • git diff --check — passed

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Scope notes

  • Targets dev only.
  • No GUI behavior or text-only product change.
  • No authentication or credential flow change.
  • No speculative malformed-tool-call repair.

Summary by CodeRabbit

  • New Features

    • Added Xiaomi MiMo as an OpenAI-compatible provider at https://api.xiaomimimo.com/v1.
    • Added support for the mimo-v2.5 model with low, medium, and high reasoning levels.
    • Added handling for unsupported higher reasoning requests while preserving custom provider settings.
  • Documentation

    • Updated provider catalogs in English, Japanese, Korean, Russian, Simplified Chinese, and Traditional Chinese.
    • Documented Xiaomi MiMo configuration and reasoning behavior.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 047eb827-a28b-4c8d-b870-9706fb02dc95

📥 Commits

Reviewing files that changed from the base of the PR and between f65dcae and 49503ea.

📒 Files selected for processing (4)
  • src/providers/registry.ts
  • structure/03_catalog-and-subagents.md
  • tests/mimo-token-plan-provider.test.ts
  • tests/provider-registry-parity.test.ts

📝 Walkthrough

Walkthrough

Adds a Xiaomi MiMo OpenAI Chat provider preset with the mimo-v2.5 model, constrained reasoning tiers, high-tier clamping, and custom-destination preservation. Updates provider tests, registry parity expectations, decision-log documentation, and localized provider catalogs.

Changes

Xiaomi MiMo provider integration

Layer / File(s) Summary
Provider preset and validation
src/providers/registry.ts, tests/mimo-token-plan-provider.test.ts, tests/provider-registry-parity.test.ts
src/providers/registry.ts:2326-2343 adds the xiaomi-mimo preset with the Xiaomi endpoint, OpenAI Chat transport, mimo-v2.5, reasoning mappings, destination handling, and dashboard metadata. tests/mimo-token-plan-provider.test.ts:2-71, 121-223 validates routing, reasoning maps, clamping, aliases, and custom-provider preservation. tests/provider-registry-parity.test.ts:38 adds gitlab-duo to the expected provider IDs.
Provider documentation and decision log
structure/03_catalog-and-subagents.md, docs-site/src/content/docs/guides/providers.md, docs-site/src/content/docs/ja/guides/providers.md, docs-site/src/content/docs/ko/guides/providers.md, docs-site/src/content/docs/ru/guides/providers.md, docs-site/src/content/docs/zh-cn/guides/providers.md, docs-site/src/content/docs/zh-tw/guides/providers.md
structure/03_catalog-and-subagents.md:160-174 records the preset behavior and maintenance requirements. The provider catalogs add Xiaomi MiMo OpenAI Chat entries. docs-site/src/content/docs/zh-tw/guides/providers.md:511 retains the A6API custom-provider wording without visible semantic change.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProviderRegistry
  participant LoginProviderConfiguration
  participant ChatAdapter
  ProviderRegistry->>LoginProviderConfiguration: configure Xiaomi MiMo endpoint and mimo-v2.5
  LoginProviderConfiguration->>ChatAdapter: route OpenAI Chat requests
  ChatAdapter-->>LoginProviderConfiguration: map reasoning effort to low, medium, or high
  LoginProviderConfiguration-->>ProviderRegistry: preserve custom destination when configured
Loading

Possibly related PRs

  • lidge-jun/opencodex#385: Adds an OpenAI-compatible provider preset and updates provider parity expectations.
  • lidge-jun/opencodex#653: Adds a first-class OpenAI-compatible provider with custom-destination preservation, documentation, and tests.
  • lidge-jun/opencodex#1315: Adds an OpenAI-compatible provider with localized documentation and registry parity coverage.

Suggested labels: review-ready

Suggested reviewers: lidge-jun, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: clamping unsupported reasoning tiers for the Xiaomi MiMo public provider.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-1483-xiaomi-reasoning

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@Ingwannu

Copy link
Copy Markdown
Owner Author

Exact-head CI follow-up for 945d1718a4ad9ff9d3babe5a2523673a1bb1bf60:

  • the first gates attempt failed in the existing GUI aggregate-suite isolation pattern; the same 25 failures reproduced on clean origin/dev, while the four owning files passed 32/32 in isolation;
  • the first macOS attempt completed 11,051 tests and timed out only in the unrelated existing Cursor blob ID key channel bounds test;
  • I reran only those two failed jobs after the parent run finalized;
  • rerun gates passed, rerun macOS passed, and workflow run 31515208300 is now completed with success at attempt 3.

All Linux shards, gates, macOS, API/storage, keyring, npm-global, React Doctor, hygiene, and target checks are therefore green on the exact PR head. No GUI or unrelated timeout change was added to this provider patch. The PR remains draft and unmerged pending independent maintainer review.

@Wibias Wibias left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the Xiaomi MiMo reasoning-contract change. I did not find an additional blocker in this scoped head. The fixed-destination preset limits the advertised ladder to low/medium/high, clamps higher direct tiers to high, and preserveCustomDestination protects same-named custom providers on other origins.

The separately reported malformed delta.tool_calls failure in #1483 is intentionally not repaired here and should remain tracked independently. I am not approving this head because it is currently not mergeable against the latest dev; rebase/resolve conflicts and request re-review.

@Wibias
Wibias force-pushed the agent/fix-1483-xiaomi-reasoning branch from 945d171 to f65dcae Compare August 11, 2026 19:39
@Wibias
Wibias marked this pull request as ready for review August 11, 2026 19:40
@Wibias
Wibias marked this pull request as draft August 11, 2026 19:42
@Wibias
Wibias marked this pull request as ready for review August 11, 2026 19:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Line 294: Document Xiaomi MiMo’s reasoning contract alongside the provider
entry: state that only low, medium, and high are supported, and that xhigh, max,
and ultra are clamped to high. Apply the equivalent localized note in
docs-site/src/content/docs/ja/guides/providers.md:221,
docs-site/src/content/docs/ko/guides/providers.md:221,
docs-site/src/content/docs/ru/guides/providers.md:232,
docs-site/src/content/docs/zh-cn/guides/providers.md:209, and
docs-site/src/content/docs/zh-tw/guides/providers.md:275, while adding the
base-language note in docs-site/src/content/docs/guides/providers.md:294.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5c3e0737-3722-4414-aa42-1093b639e040

📥 Commits

Reviewing files that changed from the base of the PR and between d91ca60 and f65dcae.

📒 Files selected for processing (10)
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-tw/guides/providers.md
  • src/providers/registry.ts
  • structure/03_catalog-and-subagents.md
  • tests/mimo-token-plan-provider.test.ts
  • tests/provider-registry-parity.test.ts

| SiliconFlow | `https://api.siliconflow.cn/v1` |
| Volcengine Ark · Coding Plan · Agent Plan | `https://ark.cn-beijing.volces.com/api/v3` · `https://ark.cn-beijing.volces.com/api/coding/v3` · `https://ark.cn-beijing.volces.com/api/plan/v3` |
| Xiaomi MiMo | `https://api.xiaomimimo.com/anthropic` |
| Xiaomi MiMo (OpenAI Chat) | `https://api.xiaomimimo.com/v1` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document the Xiaomi MiMo reasoning contract.

The new rows identify the endpoint, but they do not state that Xiaomi MiMo supports only low, medium, and high. They also do not state that xhigh, max, and ultra are clamped to high. Users can otherwise select a tier that the CLI silently changes.

  • docs-site/src/content/docs/guides/providers.md#L294-L294: Add the supported ladder and clamping behavior.
  • docs-site/src/content/docs/ja/guides/providers.md#L221-L221: Add the equivalent localized behavior note.
  • docs-site/src/content/docs/ko/guides/providers.md#L221-L221: Add the equivalent localized behavior note.
  • docs-site/src/content/docs/ru/guides/providers.md#L232-L232: Add the equivalent localized behavior note.
  • docs-site/src/content/docs/zh-cn/guides/providers.md#L209-L209: Add the equivalent localized behavior note.
  • docs-site/src/content/docs/zh-tw/guides/providers.md#L275-L275: Add the equivalent localized behavior note.

As per path instructions, user-facing docs must stay in sync with actual CLI/API behavior. The referenced adapter documentation also requires consistent documentation of provider-specific reasoning support and higher-tier clamping.

📍 Affects 6 files
  • docs-site/src/content/docs/guides/providers.md#L294-L294 (this comment)
  • docs-site/src/content/docs/ja/guides/providers.md#L221-L221
  • docs-site/src/content/docs/ko/guides/providers.md#L221-L221
  • docs-site/src/content/docs/ru/guides/providers.md#L232-L232
  • docs-site/src/content/docs/zh-cn/guides/providers.md#L209-L209
  • docs-site/src/content/docs/zh-tw/guides/providers.md#L275-L275
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs-site/src/content/docs/guides/providers.md` at line 294, Document Xiaomi
MiMo’s reasoning contract alongside the provider entry: state that only low,
medium, and high are supported, and that xhigh, max, and ultra are clamped to
high. Apply the equivalent localized note in
docs-site/src/content/docs/ja/guides/providers.md:221,
docs-site/src/content/docs/ko/guides/providers.md:221,
docs-site/src/content/docs/ru/guides/providers.md:232,
docs-site/src/content/docs/zh-cn/guides/providers.md:209, and
docs-site/src/content/docs/zh-tw/guides/providers.md:275, while adding the
base-language note in docs-site/src/content/docs/guides/providers.md:294.

Source: Path instructions

@Wibias Wibias left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review against current dev@e8db4e03: the implementation correctly limits Xiaomi MiMo to low/medium/high and clamps xhigh/max/ultra to high, but the user-facing provider guides only add the endpoint row and omit that behavior. Since users can otherwise select a tier that OpenCodex silently lowers, please document the supported ladder and clamping behavior in the base guide and the five localized provider guides touched by this PR. The branch is also 9 commits behind current dev and currently not mergeable, so please rebase after the docs fix.

@Wibias
Wibias marked this pull request as draft August 11, 2026 19:57
@lidge-jun
lidge-jun marked this pull request as ready for review August 12, 2026 16:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f65dcae833

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/providers/registry.ts
defaultModel: "mimo-v2.5",
models: ["mimo-v2.5"],
reasoningEfforts: ["low", "medium", "high"],
reasoningEffortMap: { xhigh: "high", max: "high", ultra: "high" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit none reasoning requests

When a Responses request explicitly sets reasoning.effort to none, this map has no none entry, so mapReasoningEffort() returns undefined and the OpenAI Chat adapter omits reasoning_effort entirely. Because the registry note states that Xiaomi accepts none as a distinct value, omission can invoke Xiaomi's default reasoning instead of disabling it; add none: "none" and cover the resulting request body in the focused test.

AGENTS.md reference: src/AGENTS.md:L18-L18

Useful? React with 👍 / 👎.

Comment thread src/providers/registry.ts
authKind: "key",
dashboardUrl: "https://platform.xiaomimimo.com/console/balance",
defaultModel: "mimo-v2.5",
models: ["mimo-v2.5"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Attach Xiaomi model metadata to the new preset

For users selecting this new static preset, mimo-v2.5 receives neither explicit context/modality metadata nor a jawcodeBundle: "xiaomi" alias. Consequently, the catalog cannot reach the existing Xiaomi metadata in src/generated/model-metadata.ts:53 and normalizes this model to the generic 128,000-token, text-only fallback instead of the repository's 1,048,576-token image-capable definition, causing premature compaction and blocking image attachments. Link the preset to the Xiaomi bundle and regenerate the metadata output, or declare the fields directly.

AGENTS.md reference: src/AGENTS.md:L18-L18

Useful? React with 👍 / 👎.

Ingwannu and others added 2 commits August 13, 2026 01:35
Review follow-up on top of @Ingwannu's commit. The review flagged that a
user reasoningEffortMap can lift a tier past the registry clamp, and that
is true — I reproduced it: max resolves to max, not high.

But it is the shipped contract, not an oversight. healMappedTiers treats
a wire map as authoritative evidence of the tiers an upstream can emit
and merges its Codex values into the ladder at lookup time. That is what
lets a stale persisted ladder recover a newly documented tier without
rewriting user config, and tests/reasoning-effort.test.ts pins it under
'stale reasoning-ladder self-heal'.

I first tried making the clamp win. It broke two existing tests, because
a mapped value like Kimi's  is a legitimate non-Codex wire word,
not a tier to compare against a ladder. Narrowing the clamp to Codex
tiers only still fought healMappedTiers, so I reverted it: the right
answer is that the registry clamp protects the DEFAULT route, and a user
who writes a conflicting map has deliberately opted out.

Two tests record that boundary — one for the default route where the
clamp holds, one for the overriding map — so nobody later reads the
clamp as an enforcement the code does not implement.
@lidge-jun
lidge-jun force-pushed the agent/fix-1483-xiaomi-reasoning branch from f65dcae to 49503ea Compare August 12, 2026 16:41
@lidge-jun

Copy link
Copy Markdown
Owner

Reviewed against current dev (a34d1a5a6) and rebased onto it; your commit is preserved. I pushed one test-only commit on top.

The registry preset lands as written. The fixed destination, preserveCustomDestination, and the low/medium/high ladder with xhigh/max/ultrahigh are all correct, and the tier values are evidence-backed rather than guessed — Xiaomi's docs list the accepted efforts and #1483 supplies the exact max rejection.

One review finding, and it turned out to be half right. Review flagged that a user reasoningEffortMap bypasses the clamp. I reproduced it directly:

{"efforts":["low","medium","high"],"map":{"xhigh":"high","max":"max","ultra":"ultra"},"max":"max","ultra":"max"}

So max does reach the wire as max when a user writes a conflicting map. But that is the shipped contract, not an oversight in this PR. healMappedTiers treats a wire map as authoritative evidence of the tiers an upstream can emit and merges its Codex values into the ladder at lookup time — that is what lets a stale persisted ladder recover a newly documented tier without rewriting user config, and tests/reasoning-effort.test.ts pins it under "stale reasoning-ladder self-heal".

I did try making the clamp authoritative. It broke two existing tests, because a mapped value like Kimi's none is a legitimate non-Codex wire word rather than a tier comparable to a ladder. Narrowing the clamp to Codex tiers only still fought healMappedTiers, so I reverted it. The honest reading is that the registry clamp protects the default route, and a user who writes a conflicting map has deliberately opted out — which is consistent with how every other provider ladder behaves here.

The follow-up is therefore two tests recording that boundary: one proving the clamp holds on the default route (max/ultra/xhighhigh), one proving the overriding map wins. Neither changes behavior; they stop the next reader from treating the clamp as an enforcement the code does not implement.

Verification at 49503ea0e on a Linux runner (Bun 1.3.14): bun x tsc --noEmit exit 0; 18-file reasoning/mimo/registry/router sweep 264 pass / 0 fail. Red-before for your tests: tests-only diff on dev = 2 failures.

@lidge-jun
lidge-jun merged commit bca30e5 into dev Aug 12, 2026
11 of 12 checks passed
@Wibias
Wibias deleted the agent/fix-1483-xiaomi-reasoning branch August 12, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants